﻿using System;
using WF_AppFuel.Validation.Base;
using WF_AppFuel.Validation.Engines;

namespace WF_AppFuel.Validation.Attributes
{
    /// <summary>
    /// Attribute used for specifying that a property may only contain letters
    /// or combination of letters and whitespaces, if whitespaces are allowed.
    /// </summary>
    /// <author>Arjay C. Nacion</author>
    public sealed class IsAlpha : BaseValidationAttribute
    {
        private bool allowWhiteSpace = false;

        /// <param name="allowWhiteSpace">
        /// Indicates whether whitespaces should be allowed or not.
        /// </param>
        /// 
        public IsAlpha(bool allowWhiteSpace)
        {
            this.allowWhiteSpace = allowWhiteSpace;
            this.SetValidationMessage("Must Contain Letters Only");
        }

        public override Type ValidationEngineType
        {
            get { return typeof(IsAlphaValidationEngine); }
        }

        /// <summary>
        /// Gets the property indicating if whitespaces should be allowed
        /// on the property marked by this attribute.
        /// </summary>
        public bool IsWhiteSpaceAllowed { get { return this.allowWhiteSpace; } }
    }
}
